<!DOCTYPE html>
<html>
<head>
	<title>操作配置</title>
    <include file='public/head'>
        <style>
			.layui-legend-size{font-size:14px !important;}
			.layui-nopadding{padding:0 !important;}
			.layui-overflow{overflow:auto;}
			.layui-nomargin{margin: 0 !important;}
			.layui-bottom{border-bottom:1px solid rgb(226, 226, 226);}
			.layui-input{height:30px !important; }
			.layui-form-search-item .layui-inline{margin-bottom: 5px;} 
			.layui-form-search-item label{margin-left: 15px;}
			.layui-table-page {padding: 7px 0px 0px;}
			.layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}
        </style>
</head>
<body>
	<!-- layui-tab开始 -->
	<div class="layui-tab" lay-filter="demo-tab" >
		<!-- 顶部导航菜单开始 -->
		<div class="layui-tab-nav">
			<ul class="layui-tab-title">
				{:getNav('log','config/index')}
			</ul>
		</div>	
		<!-- 顶部导航菜单结束 -->
		<!-- 搜索栏开始 -->
		<fieldset class="layui-elem-field layui-field-title layui-field-padding">
			<legend class="layui-legend-size">搜索</legend>
			<form class="layui-form table-bar" action="{:cmf_plugin_url('Log://config/index')}" lay-filter="form-bar">
				<div  class="layui-form-search-item">
				    <div class="layui-inline">
						<input type="text"  name="keywords" class="layui-input"  style="width: 200px;" value="{$search.keywords|default=''}" placeholder="关键字..." autocomplete="off">
					</div>
					<div class="layui-inline">
						<button type="submit" class="layui-btn layui-btn-sm layui-btn-primary " style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon ">&#xe615;</i>搜索</button>
					</div>
				</div>
			</form>
		</fieldset>
		<!-- 搜索栏结束 -->

		<!-- 内容开始 -->
		<form  class="layui-form" action="">
            <div class="layui-card">
		<!-- 表格内容开始 -->
		<div class="layui-card">
			<div class="layui-card-header layui-bg-gray layui-bottom">
				<a href="javascript:;" class="layui-btn layui-btn-xs add-btn" ><i class="layui-icon">&#xe654;</i>添加</a>
				<a href="javascript:;" class="layui-btn layui-btn-xs log-level-btn layui-btn-normal" ><i class="layui-icon">&#xe614;</i>日志级别设置(当前:{$levelStr})</a>
			</div>
			<div class="layui-card-body layui-nopadding " >
			    <!-- 数据表格开始 -->
    			<table  class="layui-table layui-nomargin">
                    <thead>	
                    	<tr>
                    	    <th>序号</th>
                    		<th>地址</th>
                    		<th>事件别名</th>
                    		<th>参数配置</th>
                    		<th>详情</th>
                    	</tr>
                    </thead>
                    <tbody >
                    	<volist name ="list" id="vo">
                    		<tr lay-filter="test3">
                    		    <td width="50" >{$key+1}</td>
                    			<td>{$vo.rule}</td>
                    			<td>{$vo.action_alias}</td>
                    			<td>{$vo.param}</td>
                    			<td data-cls="xx-{$vo.id}" width="90">
                    			    <button type="button"  class="layui-btn layui-btn-xs bianjiedit" data-tag={$vo.id}>编辑</button>
                    			    <button type="button"  class="layui-btn layui-btn-xs shanchudel layui-btn-danger"  data-tag={$vo.id}>删除</button>
                    			</td>
                    		</tr>
                    	</volist>
                    </tbody>
                </table>
    			<!-- 数据表格结束 -->
			</div>
		</div>
		<!-- 表格内容结束 -->
			
             <!-- 分页开始 -->
            <NOTEMPTY name="$page">
                <div class="layui-table-page">

                    <div id="layui-table-page1">

                        <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">

                            {$page|default=''}

                        </div>

                    </div>

                </div>
            </NOTEMPTY>
            <!-- 分页结束 -->

		</form>
		<!-- 内容结束 -->
	</div>
	<!-- layui-tab结束-->

    <div id="log_level" style="display:none;">
        <div style="padding:10px;">
            <div style="color:#1E9FFF;">
                <h3>级别说明</h3>
                <p>&nbsp;&nbsp;&nbsp;&nbsp;高级别: 记录所有操作信息</p>
                <p>&nbsp;&nbsp;&nbsp;&nbsp;中级别: 记录部分操作信息(rule配置中的记录)</p>
                <p>&nbsp;&nbsp;&nbsp;&nbsp;关闭: 不记录所有操作</p>
            </div>
            <fieldset class="layui-elem-field layui-field-title layui-field-padding">
			<legend class="layui-legend-size">日志记录级别设置</legend>
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="radio" name="level" value="H" title="高级别" lay-filter="sub_level"  <?php if( $level=='H')echo 'checked'; ?> >
                            <input type="radio" name="level" value="M" title="中级别" lay-filter="sub_level"  <?php if( $level=='M')echo 'checked'; ?> >
                            <input type="radio" name="level" value="OFF" title="关闭" lay-filter="sub_level"  <?php if( $level=='OFF')echo 'checked'; ?> >
                        </div>
                    </div>
                </form>
            </fieldset>
        </div>
    </div>


	<include file='public/scripts'>

	<!-- script开始-->	
	<script>
	;!function(){
		var form = layui.form
			,layer = layui.layer    //弹出层必需
			,layedit = layui.layedit  //富文本必需
			,laydate = layui.laydate  //日期选择必需
			,table = layui.table  //表格必需
			,element = layui.element;  //选项卡	
			
		//日期选择器	   
    	laydate = layui.laydate;
    	laydate.render({
    		elem: '#test1' //指定元素
    		,type:"datetime"
    	});
    	laydate.render({
    		elem: '#test2' //指定元素
    		,type:"datetime"
    	});
    	
    	//捕获页
    	$(document).on( 'click' , '.xiangqing' , function(){
    	    
    	    let classs = $( this ).parents('td').data( 'cls' );
    	    layer.open({
                type: 1,
                area: ['80%', '80%'], //宽高
                skin: 'layui-layer-rim', //加上边框
                shade: false,
                title: false, //不显示标题
                content: $( '.'+classs ), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
            });
    	} );

        
    	//捕获页
    	$(document).on( 'click' , '.log-level-btn' , function(){
    	    
    	    layer.open({
                type: 1,
                area: ['500px', '230px'], //宽高
                skin: 'layui-layer-rim', //加上边框
                shade: false,
                title: false, //不显示标题
                content: $('#log_level'), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
            });
    	} );
    	
    	//添加
    	$(document).on( 'click' , '.add-btn' , function(){
    	    
    	    layer.open({
                type: 2,
                title:'添加配置',
                btn:['保存','取消'],
                area: ['500px', '530px'], //宽高
                closeBtn: 0, //不显示关闭按钮
                shade: [0],
                content: '{:cmf_plugin_url("Log://config/add")}', 
                yes:function( index, layero ){
                   window[layero.find('iframe')[0]['name']].callbackd();
                }
            });
    	} );
    	
    	//编辑
    	$(document).on( 'click' , '.bianjiedit' , function(){
    	    let id = $(this).data( 'tag' );
    	    layer.open({
                type: 2,
                title:'修改配置',
                btn:['保存','取消'],
                area: ['500px', '530px'], //宽高
                closeBtn: 0, //不显示关闭按钮
                shade: [0],
                content: '{:cmf_plugin_url("Log://config/edit")}?id='+id, 
                yes:function( index, layero ){
                   window[layero.find('iframe')[0]['name']].callbackd();
                }
            });
    	} );
    	//删除
    	$(document).on( 'click' , '.shanchudel' , function(){
    	    let id = $(this).data( 'tag' );
    	    $.post( '{:cmf_plugin_url("Log://config/dels")}' , { id:id } , function( res ){
                
                layer.msg( res.message , {time:800} , function(){
                    if( res.code ==200 ){
                        window.location.reload();
                    }
                } );
            } );
    	} );
    	
        //监听提交
        form.on('radio(sub_level)', function(data){
            $.post( '{:cmf_plugin_url("Log://config/loglevel")}' , { value:data.value } , function( res ){
                
                layer.msg( res.message , {time:800} , function(){
                    if( res.code ==200 ){
                        window.location.reload();
                    }
                } );
            } );
            return false;
        });
    	
    	
	}();


	</script>
	<!-- script结束-->

</body>
</html>